// This program produces an ASCII art drawing of a mirror. // // This version changes the design of the mirror to be more "triangular," // which required more interesting nested for loops for the body. // Notice also that the drawBodyBottom method uses an outer for loop // that counts down instead of up. public class Mirror2 { public static void main(String[] args) { drawLine(); drawBodyTop(); drawBodyBottom(); drawLine(); } // Prints a line that appears at the top and bottom of the mirror. public static void drawLine() { System.out.print("#"); for (int line = 1; line <= 16; line++) { System.out.print("="); } System.out.println("#"); } // Prints the top half of the body of the mirror. public static void drawBodyTop() { for (int line = 1; line <= 4; line++) { System.out.print("|"); for (int space = 1; space <= -2 * line + 8; space++) { System.out.print(" "); } System.out.print("<>"); for (int dot = 1; dot <= 4 * line - 4; dot++) { System.out.print("."); } System.out.print("<>"); for (int space = 1; space <= -2 * line + 8; space++) { System.out.print(" "); } System.out.println("|"); } } // Prints the bottom half of the body of the mirror. public static void drawBodyBottom() { for (int line = 4; line >= 1; line--) { System.out.print("|"); for (int space = 1; space <= -2 * line + 8; space++) { System.out.print(" "); } System.out.print("<>"); for (int dot = 1; dot <= 4 * line - 4; dot++) { System.out.print("."); } System.out.print("<>"); for (int space = 1; space <= -2 * line + 8; space++) { System.out.print(" "); } System.out.println("|"); } } }